{include file="header.html"}
<script src="templates/jsnew/MediaStreamRecorder.js"> </script>
<script src="http://api.map.baidu.com/api?v=2.0&ak=kkA94xvGPjnprY92WU4yYME8"></script>
<script>
	$(function(){
		$("[id^='h_type_']").live("change",function(){
			var type = $(this).val();
			if(type==1){
				$(this).parent().parent().find('.range').hide();
			}else{
				$(this).parent().parent().find('.range').show();
			}
		});
		$('#g_tgdate').datetimepicker({changeMonth: true,changeYear: true});
		$('#g_rdate').datetimepicker({changeMonth: true,changeYear: true});
		$('#g_loading_date').datetimepicker({changeMonth: true,changeYear: true});
		$('#g_unloading_date').datetimepicker({changeMonth: true,changeYear: true});
		$('#car_form').validate({
			errorPlacement: function(error, element){
			},
			success       : function(element){
				$(element).next('.noerror').show();
				$(element).remove();
			},
			rules : {
				g_owner : {
					required : true
				},
				g_owner_tel :{
					required : true
				},
				g_loading_place :{
					required : true
				},
				g_loading_date :{
					required : true
				},
				g_unloading_place :{
					required : true
				},
				g_unloading_date :{
					required : true
				},
				g_consignee :{
					required : true
				},
				g_consignee_tel :{
					required : true
				},
				g_consignor :{
					required : true
				},
				g_consignor_tel :{
					required : true
				}
			},
			messages : {
				g_owner : {
					required : '货主必填'
				},
				g_owner_tel : {
					required : '货主电话必填'
				},
				g_loading_place : {
					required : '装货地必填'
				},
				g_loading_date : {
					required : '装货时间必填'
				},
				g_unloading_place : {
					required : '卸货地必填'
				},
				g_unloading_date : {
					required : '卸货时间必填'
				},
				g_consignee : {
					required : '收货人必填'
				},
				g_consignee_tel : {
					required : '收货人电话必填'
				},
				g_consignor : {
					required : '发货人必填'
				},
				g_consignor_tel : {
					required : '发货人电话必填'
				}
			}
		});
		$('#paiche_form').validate({
			errorPlacement: function(error, element){
			},
			success       : function(element){
				$(element).next('.noerror').show();
				$(element).remove();

			},
			rules : {
				operator : {
					required : true
				},
				wm_vhc_code :{
					required : true
				},
				wm_driver :{
					required : true
				},
				wm_driver_tel :{
					required : true
				}
			},
			messages : {
				operator : {
					required : '承运商必填'
				},
				wm_vhc_code : {
					required : '车牌号必填'
				},
				wm_driver : {
					required : '司机必填'
				},
				wm_driver_tel : {
					required : '司机电话必填'
				}
			}
		});
		$("[id^='g_volume_']").live('focus',function(){
			$(this).removeClass("error");
		});
		$("[id^='g_ctn_no_']").live('focus',function(){
			$(this).removeClass("error");
		});

		$("[id^='del_']").live('click',function(){
			var i=$(this).attr("item");
			var t=$(this);
			if(confirm("是否要删除此行?")){
				if(i>0){
					$.ajax({
						type: "post",
						url: "index.php?app=waybill&act=delsub",
						data: {id:i},
						dataType: "json",
						success: function(data){
							if(data.done){
								t.parent().parent().remove();

								if($("#huo").find("tr").length==0){
									addrow();
								}
							}else{
								alert(data.msg);
							}
						}
					});
				}else{
					$(this).parent().parent().remove();

					if($("#huo").find("tr").length==0){
						addrow();
					}
				}
			}
		});

		$("#wm_zmmtid").change(function(){
			//ajax处理
			var id = $("#wm_tid").val();
			var mid = $(this).val();
			if(mid==''){
				alert('请选择监控方案');
				return false;
			}
			$.ajax({
				type: "post",
				url: "index.php?app=carload&act=monitor",
				data: {id:id,mid:mid},
				dataType: "json",
				success: function(data){
					if(data.done){
						//成功的提示
						$("#syss").text(data.msg);
						$("#syss").slideDown();
						setTimeout(function(){
							$("#syss").slideUp();
						},2000);
					}else{
						alert(data.msg);
					}
				}
			});
			//window.location.href="index.php?app=carload&act=monitor&id="+$("#wm_tid").val()+"&mid="+$(this).val();
		});

		$("#yuncheng").change(function(){
			if(confirm("确认删除现运程,引入新方案吗?")){
				window.location.href="index.php?app=carload&act=hauldefine&id="+$("#wm_tid").val()+"&hid="+$(this).val();
			}
		});
		//货主
		$("#himg").live('click',function(){
			$w=$(window).width();
			$h=$(window).height();
			$w=$w*0.7;
			$("#hzframe").attr("src","index.php?app=datarefer&act=choosehz");
			$("#hzframe").width($w);
			$.colorbox({
				width : $w+20,
				height : "650px",
				inline : true,
				href : "#hzlist"
			});
		});
		//承运商
		$("#operatorshowa").click(function(){
			$w=$(window).width();
			$h=$(window).height();
			$w=$w*0.7;
			$("#opframe").attr("src","index.php?app=datarefer&act=chooseop&wid="+$("#wm_tid").val());
			$("#opframe").width($w);
			$.colorbox({
				width : $w+20,
				height : "650px",
				inline : true,
				href : "#oplist"
			});
		});
		//车牌号
		$("#wm_vhc_code").click(function(){
			$w=$(window).width();
			$h=$(window).height();
			$w=$w*0.7;
			$("#pcframe").attr("src","index.php?app=datarefer&act=choose&wid="+$("#wm_tid").val()+"&oper="+$("#operator").val());
			$("#pcframe").width($w);
			$.colorbox({
				width : $w+20,
				height : "650px",
				inline : true,
				href : "#pclist"
			});
		});
		
		$("#cimg").click(function(){
			$w=$(window).width();
			$h=$(window).height();
			$w=$w*0.7;
			$("#pcframe").attr("src","index.php?app=datarefer&act=choose&wid="+$("#wm_tid").val()+"&oper="+$("#operator").val());
			$("#pcframe").width($w);
			$.colorbox({
				width : $w+20,
				height : "650px",
				inline : true,
				href : "#pclist"
			});
		});
		//调用添加采集信息点击事件
		$(".addhandle2").on("click",addhandle);
	});

	var f=100000;
	var i=1000000;
	function addhaul(){
		var t=$("#templete_haul").html();
		f++;
		i++;
		t=t.replace(/{num}/g,f).replace(/{fig}/g,i);
		$("#div_haul").append(t);
		//给模版绑定事件
		$(".addhandle2:last").on("click",addhandle);
	}
	function addhandle(){
		var th=$("#templete_handle").html();
		i++;
		var oldValue=parseInt($(this).attr('dig'));//取出现在的值，并使用parseInt转为int类型数据
		oldValue++;//自加1
		$(this).attr('dig',oldValue);
		var haul_num = $(this).attr('var');
		th=th.replace(/{num}/g,haul_num).replace(/{fig}/g,i).replace(/{c}/g,oldValue);
		$(this).parents(".itemdiv").append(th);

	}
	function cargotimeimg (type,number,id){
		
		if(type==1){
			if(number==1){
				$('#g_loading_date'+id).focus();
			}else if(number==2){
				$('#g_unloading_date'+id).focus();
			}else if (number==3){
				$('#g_tgdate'+id).focus();
			}else if(number==4){
				$('#g_rdate'+id).focus();
			}
		}else if(type==3){
			
			$('#h_required_service_date_'+id).focus();
		}
	}
	//货主新弹框
	function changehz(id,name,hzid,linkman,linktel){
		$('hzframe').colorbox.close();
		$("#g_ownertid").val(id);
		$("#g_owner").val(name);
		$("#g_owner_tel").val(linktel);
	}
	//承运商
	function changeop(id,name){
		$('opframe').colorbox.close();
		$("#operator").val(id);
		$("#operatorshow").val(name);
	}
	var mediaRecorder={};
	function onMediaSuccess(stream) {
		mediaRecorder = new MediaStreamRecorder(stream);
		mediaRecorder.mimeType = 'audio/ogg';
		mediaRecorder.audioChannels = 1;
		mediaRecorder.ondataavailable = function (blob) {

			var fileType = 'video'; // or "audio"
			var fileName = 'wm_requiredl_note_voice.ogg';  // or "wav" or "ogg"

			var formData = new FormData();
			formData.append(fileType + '-filename', fileName);
			formData.append(fileType + '-blob', blob);

			xhr('index.php?app=upload', formData, function (fileURL) {
				window.open(fileURL);
			});

			function xhr(url, data, callback) {
				var request = new XMLHttpRequest();
				request.onreadystatechange = function () {
					if (request.readyState == 4 && request.status == 200) {
						//callback(location.href + request.responseText);
						$("#wm_requiredl_note_voice").val(request.responseText);
					}
				};
				request.open('POST', url);
				request.send(data);
			}
		};
		mediaRecorder.start(10*60*1000);
	}
	function start(){
		$("#stopbtn").show();
		$("#startbtn").hide();
		var mediaConstraints = {audio: true};
		navigator.getUserMedia(mediaConstraints, onMediaSuccess, onMediaError);
	}

	function stop(){
		if(typeof mediaRecorder.stop=='function'){
			mediaRecorder.stop();
			$("#stopbtn").hide();
			$("#startbtn").show();
		}
	}

	function onMediaError(e) {
		console.error('media error', e);
	}

	var mainid=0;
	var mapsender=null;
	var newmapid;
	//地图选择
	function mapselect(mapid,id,sender){
	    newmapid=mapid;
		mainid=id;
		mapsender=sender;
		$w=$(window).width();
		$h=$(window).height();
		$w=$w*0.7;
		$("#mapframe").attr("src","index.php?app=datarefer&act=mapselect&lng="+parseFloat($("[id='lng_"+mainid+"']").val())+"&lat="+parseFloat($("[id='lat_"+mainid+"']").val())+"&ret=window.parent.mapresult&address="+$(mapid).val());
		$("#mapframe").width($w);
		$.colorbox({
			width : $w+20,
			height : "650px",
			inline : true,
			href : "#maplist"
		});
	}

	function mapresult(lng,lat,addr){
		$('mapframe').colorbox.close();
		$("[id='lat_"+mainid+"']").val(lat);
		$("[id='lng_"+mainid+"']").val(lng);
		if(mapsender!=null){
			$(mapsender).html()
		}

        if(newmapid=="#g_loading_place"){
			$("#g_loading_place").val(addr);
		}
        if(newmapid=="#g_unloading_place"){
			$("#g_unloading_place").val(addr);
		}
        if(newmapid=="#haul_"+mainid+"_h_address"){
			$("#haul_"+mainid+"_h_address").val(addr);
		}
		
		if(lat>0&&lng>0){
			$("#mapimg_"+mainid).attr("src","templates/images/newadmin/map1.png");
		}

	}

	//监控方案详情
	function monitorinfo(mid){
		var wm_zmmtid = $("#wm_zmmtid").val();
		if(wm_zmmtid=='' || wm_zmmtid==0){
			alert('请先选择监控方案，再查看详情');
			return false;
		}
		$w=$(window).width();
		$h=$(window).height();
		$w=$w*0.7;
		$("#monitorframe").attr("src","index.php?app=datarefer&act=monitorinfo&mid="+wm_zmmtid);
		$("#monitorframe").width($w);
		$.colorbox({
			width : $w+20,
			height : "650px",
			inline : true,
			href : "#monitorlist"
		});
	}
	function huozhu(textid,tel,valueid){
		var v=$("#"+textid).val();
		var urlval=$("#"+textid).attr("urlval");
		if(v!=""&&v!=null){
			$.ajax({
				type: "GET",
				url: urlval,
				data: {q:v},
				dataType: "json",
				success: function(data){
					if(!data.done){
						$("#"+valueid).val(0);
						$("#"+textid).val("");
						$("#"+tel).val("");
					}else{
						$("#"+valueid).val(data.retval.id);
						$("#"+textid).val(data.retval.text);
						$("#"+tel).val(data.retval.o_linktel);
					}
				}
			});
		}else{
			$("#"+valueid).val(0);
			$("#"+textid).val("");
			$("#"+tel).val("");
		}
	}

	function gethz(textid,tel,valueid){
		var url=$("#"+textid).attr("urldata");
		var urlval=$("#"+textid).attr("urlval");
		if(url==undefined||url==null||url==""||urlval==undefined||urlval==null||urlval==""){
			return;
		}
		AutoComplete({
			EmptyMessage: "没有数据",
			Url: url,
			_Select: function(item) {
				$("#"+textid).unbind("blur");
				$("#"+textid).val($(item).text());
				var attr = $(item).attr("data-autocomplete-value");
				var arr = attr.split(';');
				$("#"+valueid).val(arr[0]);
				$("#"+tel).val(arr[2]);
				if(valueid!=undefined&&valueid!=""&&valueid!=null){
					$("#"+valueid).val(arr[0]);
				}
				$("#"+textid).bind('blur',function(){
					huozhu(textid,tel,valueid);
				});
			}
		}, "#"+textid);
	}
</script>
<style>
.infoTable{
margin: 0 0 0 0;
}
.info th {
    text-align: right;
    
}
#form11 th,#form1 th{
text-align: right;
    padding-right: 15px;
}
.infoTableInput,.infoTable select{
	width: 100%;
}
.grayb{background: #eee;}
.info td a{color: #1874CD}
.itemdiv .querySelect{height: 23px;
   width:200px;
    border: 1px solid #ccc;
    outline: 0;
    font-size: 14px;
    line-height: 19px;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;}
    .itemdiv .infoTableInput{height: 23px;
   width:300px;
    padding: 0 5px;
    border: 1px solid #ccc;
    outline: 0;
    font-size: 14px;
    line-height: 19px;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;}

a.btn_add,.rmlink{
	display: inline-block !important;
	height: 23px;
	margin: 5px;
	padding: 0 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	outline: 0;
	background-image: none;
	background-color: #fff;
	font-size: 12px;
	font-weight: 400;
	line-height: 23px;
	color: #1a1a1a;
	text-align: center;
	vertical-align: top;
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	-o-box-sizing: border-box;
	background-color: #0ae;
	border-color: #0ae;
	color: #fff;
	text-shadow: none;
}
.haul_div{
	border-left: 4px solid #76b5ea;
	border-top: 1px solid #d3dae0;
	border-bottom: 1px solid #d3dae0;
	border-right: 1px solid #d3dae0;
	margin: 10px 10px 0 20px;
}
</style>
<div id="templete_haul" style="display: none">
	<div class = "haul_div">
		<table class="infoTable tt" style="width:98%;padding: 10px 0 0 0">
			<tr>
				<th class="paddingT15">运程:</th>
				<td class="paddingT15 wordSpacing5">
					<input class="infoTableInput" type="text" name="haul[{num}][h_name]" value="" />
					<input type="hidden" name="haul[{num}][h_tid]" value="" />
				</td>
				<th class="paddingT15">联系人: </th>
				<td class="paddingT15 wordSpacing5">
					<input 	class="infoTableInput" type="text" name="haul[{num}][h_linkman]" value=""  />
				</td>
				<th class="paddingT15">电话:</th>
				<td class="paddingT15 wordSpacing5">
					<input 	class="infoTableInput" type="text" name="haul[{num}][h_linkman_tel]" value="" />
				</td>
				<th class="paddingT15">确认类型:</th>
				<td class="paddingT15 wordSpacing5">
					<select class="querySelect" name="haul[{num}][h_type]" id="h_type_{num}">
						{html_options options=$typelist selected=$h.h_type}
					</select>
				</td>
				<th class="paddingT15 range">运程范围:</th>
				<td class="paddingT15 wordSpacing5 range">
					<input class="infoTableInput" placeholder="请填写数字" type="text" name="haul[{num}][h_range]" value="" />
				</td>
			</tr>
			<tr>
				<th class="paddingT15">状态:</th>
				<td class="paddingT15 wordSpacing5" style="font-size: 14px">
					未开始
				</td>
				<th class="paddingT15">时间:</th>
				<td class="paddingT15 wordSpacing5" >
					<input 	class="infoTableInput" type="text" name="haul[{num}][h_required_service_date]"
							  value="-" id="h_required_service_date_{num}" />
					<script>
						$("#h_required_service_date_{num}").datetimepicker({changeMonth: true,changeYear: true});
					</script>
					<a href="javascript:void(0);" onclick="timeimg('3','1',{num});"  class="right_a">
						<img src="templates/images/newadmin/rili.png" alt="">
					</a>
				</td>
				<th class="paddingT15">要求:</th>
				<td class="paddingT15 wordSpacing5" >
					<input 	class="infoTableInput" type="text" name="haul[{num}][h_note]" value=""  />
				</td>
				<th class="paddingT15">地址:</th>
				<td class="paddingT15 wordSpacing5">
					<input type="hidden" value="" name="haul[{num}][h_lat]" id="lat_{num}">
					<input type="hidden" value="" name="haul[{num}][h_lng]" id="lng_{num}">
					<input class="infoTableInput" type="text" name="haul[{num}][h_address]" value="" id="haul_{num}_h_address"  />
					<a href="javascript:void(0);" onclick="mapselect('#haul_{num}_h_address',{num},this);" class="right_a">
						<img src="templates/images/newadmin/map.png" alt="" id="mapimg_{num}">
					</a>
				</td>
			</tr>
		</table>
		<div style="padding: 0 0 0 50px" class="itemdiv">
			<a class="addhandle addhandle2 btn_add" var="{num}" dig=1>采集信息</a>
			<div style="padding: 2px 0;">
				<input type="hidden" name="haul[{num}][item][{fig}][hc_tid]" value="" />
				<span style="background: #ccccce;display: block;padding: 5px 8px;float: left">1</span>
				<p style="float: left;margin: 0 40px">操作：
					<select class="querySelect" name="haul[{num}][item][{fig}][h_collect_type]" >
						{html_options options=$ctype}
					</select>
				</p>
				<p style="float: left;margin: 0 40px">说明：<input class="infoTableInput" type="text" name="haul[{num}][item][{fig}][h_collect_des]" value="" style="float: none"/></p>
				<div style="clear: both"></div>
			</div>
		</div>
	</div>
</div>
<div id="templete_handle" style="display: none">
	<div style="padding: 2px 0;">
		<input type="hidden" name="haul[{num}][item][{fig}][hc_tid]" value="" />
		<span style="background: #ccccce;display: block;padding: 5px 8px;float: left">{c}</span>
		<p style="float: left;margin: 0 40px">操作：
			<select class="querySelect" name="haul[{num}][item][{fig}][h_collect_type]" >
				{html_options options=$ctype}
			</select>
		</p>
		<p style="float: left;margin: 0 40px">说明：<input class="infoTableInput" type="text" name="haul[{num}][item][{fig}][h_collect_des]" value="" style="float: none"/></p>
		<div style="clear: both"></div>
	</div>
</div>
<div id="rightTop">
	<p>整车运单 <lable id="typeshow" style="font-weight: bold;">[{$waybill.wm_type}]</lable> {$waybill.wm_code} [{$waybill.wm_stauts}]</p>
	<ul class="subnav">
		<li><a class="btn1" href="index.php?app=carload">{$lang.manage}</a>
		</li>
		<!-- {if $wm_tid}} -->
		<li>
			<a class="btn1" href="index.php?app=carload&amp;act=add">{$lang.add}</a>
		</li>
		<li>
			<span>编辑</span>
		</li>
		<!-- {else} -->
		<li>
			<span>新建</span>
		</li>
		<!-- {/if} -->
	</ul>
</div>
<div class="info">
	<div class="mask" id="mask">
		<div><img src="templates/images/loading.gif"></div>
	</div>
	<form method="post" enctype="multipart/form-data" id="car_form">
		<table class="infoTable">
			<tr>
				<th  class="paddingT15">
					<b style="color: #ff0000">*&nbsp;</b>货主:
				</th>

				<td >
				<input type="hidden" value="{$carload.g_ownertid}" name="g_ownertid" id="g_ownertid">
				<input type="text"  placeholder="货主必填" value="{$carload.g_owner}" 
				name="g_owner" id="g_owner" 
				class="infoTableInput "
				urldata="index.php?app=datarefer&act=gethz" urlval="index.php?app=datarefer&act=gethzinfo"
				>
					<a href="javascript:void(0);" class="right_a" id="himg" ><img src="templates/images/newadmin/serch.png" alt=""></a>
				
				<script>
					gethz("g_owner","g_owner_tel","g_ownertid");
				</script>
				</td>
             	<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>货主电话:  </th>
             	<td >
					<input type="text" placeholder="货主电话必填" value="{$carload.g_owner_tel}" name="g_owner_tel" id="g_owner_tel" class="infoTableInput">
             	</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>车型:</th>
				<td class="paddingT15 wordSpacing5" >
					<select class="querySelect" name="g_cartype" >
						{html_options options=$car_types selected=$carload.g_cartype}
					</select>
				</td>
            </tr>
			<tr>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>发货人:  </th>
				<td >
					<input type="text" placeholder="发货人必填" value="{$carload.g_consignor}" name="g_consignor" id="g_consignor" class="infoTableInput">
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>发货人电话: </th>
				<td>
					<input type="text" placeholder="发货人电话必填" value="{$carload.g_consignor_tel}" name="g_consignor_tel" id="g_consignor_tel" class="infoTableInput">
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>装货时间:</th>
				<td class="paddingT15 wordSpacing5">
					<input placeholder="装货时间必填"  class="infoTableInput" type="text" name="g_loading_date" id="g_loading_date" value="{if $carload.g_loading_date}{$carload.g_loading_date|date:Y-m-d H:i}{else}{/if}" />
					<a href="javascript:void(0);" onclick="cargotimeimg('1','1','');" class="right_a"><img src="templates/images/newadmin/rili.png" alt=""></a>
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>装货地:  </th>
				<td>
					<input type="hidden" value="{$carload.g_loading_lng}" name="g_loading_lng" id="lng_loading"><!--经度-->
					<input type="hidden" value="{$carload.g_loading_lat}" name="g_loading_lat" id="lat_loading">
					<input type="text" placeholder="装货地必填" value="{$carload.g_loading_place}" name="g_loading_place" id="g_loading_place" class="infoTableInput" urldata="index.php?app=datarefer&act=getaddr" urlval="index.php?app=datarefer&act=getaddrinfo">
					<a href="javascript:void(0);" onclick="mapselect('#g_loading_place','loading',this)" class="right_a">
						{if $carload.g_loading_lat>0&&$carload.g_loading_lng>0}
						<img src="templates/images/newadmin/map1.png" alt="" id="mapimg_loading">
						{else}
						<img src="templates/images/newadmin/map.png" alt="" id="mapimg_loading">{/if}
					</a>
					<script>
						addrrefer("g_loading_place","lng_loading","lat_loading","mapimg_loading");
					</script>
				</td>
			</tr>
			<tr>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>收货人:  </th>
				<td >
					<input type="text" placeholder="收货人必填" value="{$carload.g_consignee}" name="g_consignee" id="g_consignee" class="infoTableInput">
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>收货人电话: </th>
				<td >
					<input type="text" placeholder="收货人电话必填" value="{$carload.g_consignee_tel}" name="g_consignee_tel" id="g_consignee_tel" class="infoTableInput">
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>卸货时间:</th>
				<td class="paddingT15 wordSpacing5">
					<input placeholder="卸货时间必填"  class="infoTableInput" type="text" name="g_unloading_date" id="g_unloading_date" value="{if $carload.g_unloading_date}{$carload.g_unloading_date|date:Y-m-d H:i}{else}{/if}" />
					<a href="javascript:void(0);" onclick="cargotimeimg('1','2','');"  class="right_a"><img src="templates/images/newadmin/rili.png" alt=""></a>
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b> 卸货地: </th>
				<td>
					<input type="hidden" value="{$carload.g_unloading_lng}" name="g_unloading_lng" id="lng_unloading"><!--经度-->
					<input type="hidden" value="{$carload.g_unloading_lat}" name="g_unloading_lat" id="lat_unloading">
					<input type="text" placeholder="卸货地必填" value="{$carload.g_unloading_place}" name="g_unloading_place" id="g_unloading_place" class="infoTableInput" urldata="index.php?app=datarefer&act=getaddr" urlval="index.php?app=datarefer&act=getaddrinfo">
					<a href="javascript:void(0);" onclick="mapselect('#g_unloading_place','unloading',this);" class="right_a">
						{if $carload.g_unloading_lat>0&&$carload.g_unloading_lng>0}
						<img src="templates/images/newadmin/map1.png" alt="" id="mapimg_unloading">
						{else}
						<img src="templates/images/newadmin/map.png" alt="" id="mapimg_unloading">{/if}
					</a>
					<script>
						addrrefer("g_unloading_place","lng_unloading","lat_unloading","mapimg_unloading");
					</script>
				</td>
			</tr>
			<tr>
				<th class="paddingT15">备注:</th>
				<td class="paddingT15 wordSpacing5" colspan="8">
					<textarea name="g_note" id="g_note" rows="3" style="width: 100%" >{$carload.g_note}</textarea>
				</td>
			</tr>
			<tr>
				<th></th>
				<td class="ptb20" colspan="7" style="text-align: left">
					{if $canedit}
					<input id="formbtn" class="formbtn" type="submit" name="Submit" value="{$lang.submit}"/>
					{/if}
				</td>
			</tr>
		</table>
	</form>

{if $waybill.wm_tid}
<form method="post" enctype="multipart/form-data" id="paiche_form" action="index.php?app=carload&act=pcsave">
	<input type="hidden" value="{$waybill.wm_tid}" name="wm_tid" id="wm_tid">

	<div class="jui-cut-label fn-mt25">
		<div class="jui-message-bar">派车信息
			<a style="float: right;margin-right: 20px" onclick="monitorinfo()">查看监控方案</a>
			<p style="float: right">监控方案：
				<select {if !$canedit}disabled="disabled"{/if} class="querySelect" name="wm_zmmtid" id="wm_zmmtid">
				<option value="">请选择监控方案</option>
				{html_options options=$monitor selected=$waybill.wm_zmmtid}
				</select>
			</p>
		</div>
	</div>
	<table class="infoTable">
		<tr>
			<input type="hidden" value="{$waybill.wm_carrier_id}" name="operator" id="operator">
			<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>{$lang.wm_carrier}:</th>
		
				<td class="paddingT15 wordSpacing5">
				<input
					class="infoTableInput" id="operatorshow" type="text"
					name="operatorshow" value="{$waybill.wm_carrier}" urldata="index.php?app=datarefer&act=getcys" urlval="index.php?app=datarefer&act=getcysinfo"/>
					<a href="javascript:void(0);" class="right_a" id="operatorshowa"><img src="templates/images/newadmin/serch.png" alt=""></a>
					<script>
				refer("operatorshow","operator");
				</script>
					</td>
			
			
			<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>{$lang.wm_vhc_code}:</th>
			<td class="paddingT15 wordSpacing5" style="position: relative;">
				<input 	class="infoTableInput" id="wm_vhc_code" type="text" name="wm_vhc_code" value="{$waybill.wm_vhc_code}" />
				{if $canedit&&$waybill.wm_tid>0}
					<a href="javascript:void(0);" class="right_a"><img id="cimg" src="templates/images/newadmin/serch.png" alt=""></a>
				{/if}
			</td>
			<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>{$lang.wm_driver}:</th>
			<td class="paddingT15 wordSpacing5">
				<input 	class="infoTableInput" id="wm_driver" type="text" name="wm_driver" value="{$waybill.wm_driver}" />
			</td>
			<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>{$lang.wm_driver_tel}:</th>
			<td class="paddingT15 wordSpacing5">
				<input class="infoTableInput" id="wm_driver_tel" type="text" name="wm_driver_tel" value="{$waybill.wm_driver_tel}" />
			</td>
		</tr>
		<tr>
			<th class="paddingT15">发车要求:</th>
			<td class="paddingT15 wordSpacing5" colspan="3" >
				<input type="hidden" id="wm_requiredl_note_voice" name="wm_requiredl_note_voice" value="{$waybill.wm_requiredl_note_voice}"/>
				{if $waybill.wm_requiredl_note_voice}
				<audio controls="controls">
					<source src="{$waybill.wm_requiredl_note_voice}" type="audio/ogg">
					你的浏览器太老了，请更新否则没法听语音
				</audio>
				{/if}
				<textarea  name="wm_requiredl_note" id="wm_requiredl_note" rows="3" style="width: 100%">{$waybill.wm_requiredl_note}</textarea>
			</td>
		</tr>
		{if 1==0}
			{if $canedit}
			<tr>
				<th class="paddingT15">录音:</th>
				<td class="paddingT15 wordSpacing5" colspan="3" style="text-align: left">
					<input type="hidden" id="wm_requiredl_note_voice" name="wm_requiredl_note_voice" value="{$waybill.wm_requiredl_note_voice}"/>
					{if $waybill.wm_requiredl_note_voice}
					<audio controls="controls">
						<source src="{$waybill.wm_requiredl_note_voice}" type="audio/ogg">
						你的浏览器太老了，请更新否则没法听语音
					</audio>
					{/if}
					{if $waybill.wm_stauts=='新建'||$waybill.wm_stauts=='已接单'}
						<input type="button" onclick="start()" value="录音" id="startbtn"/>
						<input type="button" onclick="stop()" value="停止"  id="stopbtn" style="display: none"/>
					{/if}
				</td>
			</tr>
			{/if}
		{/if}
		<tr>
			<th class="paddingT15">{$lang.wm_dispatch_person}:</th>
			<td class="paddingT15 wordSpacing5">
				<input	class="infoTableInput" id="wm_dispatch_person" type="text" readonly="readonly"
					name="wm_dispatch_person" value="{$waybill.wm_dispatch_person}" style="border: 0;" />
			</td>
			<th class="paddingT15">{$lang.wm_dispatch_person_tel}:	</th>
			<td class="paddingT15 wordSpacing5">
				<input 	class="infoTableInput" id="wm_dispatch_person_tel" type="text" readonly="readonly" name="wm_dispatch_person_tel" 	value="{$waybill.wm_dispatch_person_tel}" style="border: 0;" />
			</td>
			<th class="paddingT15">{$lang.wm_dispatch_date}:</th>
			<td class="paddingT15 wordSpacing5"><input
					class="infoTableInput" id="wm_dispatch_date" type="text" readonly="readonly"
					name="wm_dispatch_date" value="{$waybill.wm_dispatch_date|date:Y-m-d H:i}" style="border: 0;" />
			</td>
		</tr>
		{if $canedit}
			<tr>
				<th></th>
				<td class="ptb20" colspan="7" style="text-align: left">
					<input class="formbtn" type="submit" name="Submit" value="保存"/>
					<a class="formbtn" type="button" href="index.php?app=carload&act=paichedone&wm_tid={$waybill.wm_tid}&wm_user={$waybill.wm_user}" name="Submit" >发车</a>
				</td>
			</tr>
		{/if}
	</table>
</form>
{/if}
{if $waybill.wm_tid}
<form method="post" enctype="multipart/form-data" action="index.php?app=carload&act=hauledit">
	<input type="hidden" value="{$waybill.wm_tid}" name="wm_tid">
	<div class="jui-cut-label fn-mt25">
		<div class="jui-message-bar">运程信息
			<p style="float: right">{if $canedit}运程方案：<select {if !$canedit}disabled="disabled"{/if} class="querySelect" id="yuncheng">
				<option value="">请选择运程方案</option>{html_options options=$hauldefine}</select>{/if}</p>
			{if $canedit}
			<a style="float: right;margin-right: 20px" onclick="addhaul();">添加运程</a>
			{/if}
		</div>
	</div>
	<style>
		.tt th{width: 70px}
	</style>

	<div id="div_haul">
	{foreach from=$haullist item=h}
	<div class="haul_div">
		<table class="infoTable tt" style="width:98%;padding: 10px 0 0 0">
			<tr>
				<th class="paddingT15">运程:</th>
				<td class="paddingT15 wordSpacing5">
					<input
							class="infoTableInput" type="text"
							name="haul[{$h.h_tid}][h_name]" value="{$h.h_name}" />

					<input type="hidden" name="haul[{$h.h_tid}][h_tid]" value="{$h.h_tid}" />
				</td>

				<th class="paddingT15">联系人:
				</th>
				<td class="paddingT15 wordSpacing5"><input
						class="infoTableInput" type="text"
						name="haul[{$h.h_tid}][h_linkman]" value="{$h.h_linkman}"  /></td>

				<th class="paddingT15">电话:
				</th>
				<td class="paddingT15 wordSpacing5"><input
						class="infoTableInput" type="text"
						name="haul[{$h.h_tid}][h_linkman_tel]" value="{$h.h_linkman_tel}" /></td>

				<th class="paddingT15">确认类型:
				</th>
				<td class="paddingT15 wordSpacing5">
					<select class="querySelect" name="haul[{$h.h_tid}][h_type]" id="h_type_{$h.h_tid}" >{html_options options=$typelist selected=$h.h_type}</select>
				</td>
				<th class="paddingT15 range" style="display:{if $h.h_type==1}none{/if}">运程范围:</th>
				<td class="paddingT15 wordSpacing5 range" style="display:{if $h.h_type==1}none{/if}">
					<input class="infoTableInput" placeholder="请填写数字" type="text" name="haul[{$h.h_tid}][h_range]"  value="{$h.h_range}" />
				</td>
			</tr>
			<tr>
				<th class="paddingT15">状态:</th>
				<td class="paddingT15 wordSpacing5" style="font-size: 14px">
					{if $h.h_finished==0}未开始{/if}{if $h.h_finished==-1}异常{/if}{if $h.h_finished==2}完成{/if}
					{if $h.h_finished_date}{$h.h_finished_date|date:Y-m-d H:i}{/if}
				</td>
				<th class="paddingT15">时间:</th>
				<td class="paddingT15 wordSpacing5" >
					<input
							class="infoTableInput" type="text"
							name="haul[{$h.h_tid}][h_required_service_date]"
							value="{if $h.h_required_service_date}{$h.h_required_service_date|date:Y-m-d H:i}{else}-{/if}"
							id="h_required_service_date_{$h.h_tid}" />
					{if $canedit}
					<script>
						$('#h_required_service_date_{$h.h_tid}').datetimepicker({changeMonth: true,changeYear: true});
					</script>
					{/if}<a href="javascript:void(0);" onclick="cargotimeimg('3','1',{$h.h_tid});" class="right_a"><img src="templates/images/newadmin/rili.png" alt=""></a>
				</td>



				<th class="paddingT15">要求:</th>
				<td class="paddingT15 wordSpacing5" >
					<input
							class="infoTableInput" type="text"
							name="haul[{$h.h_tid}][h_note]" value="{$h.h_note}"  />
				</td>
				<th class="paddingT15">地址:</th>
				<td class="paddingT15 wordSpacing5">
					<input type="hidden" value="{$h.h_lat}" name="haul[{$h.h_tid}][h_lat]" id="lat_{$h.h_tid}">
					<input type="hidden" value="{$h.h_lng}" name="haul[{$h.h_tid}][h_lng]" id="lng_{$h.h_tid}">
					<input
							class="infoTableInput" type="text"
							name="haul[{$h.h_tid}][h_address]" value="{$h.h_address}" id="haul_{$h.h_tid}_h_address"  />
					<a href="javascript:void(0);" onclick="mapselect('#haul_{$h.h_tid}_h_address',{$h.h_tid},this);" class="right_a">
						{if $h.h_lat>0&&$h.h_lng>0}<img src="templates/images/newadmin/map1.png" alt="" id="mapimg_{$h.h_tid}">{else}<img src="templates/images/newadmin/map.png" alt="" id="mapimg_{$h.h_tid}">{/if}</a>
				</td>
			</tr>
		</table>
		<div style="padding: 0 0 0 50px" class="itemdiv">
			{if $canedit && $h.h_finished==0}
			<a class="addhandle2 btn_add" var="{$h.h_tid}" dig="{$h.item|modifier:getcount}" >采集信息</a>
			{/if}
			{foreach from=$h.item item=i name=it}
			<div style="padding: 2px 0;">
				<input type="hidden" name="haul[{$h.h_tid}][item][{$i.hc_tid}][hc_tid]" value="{$i.hc_tid}" />
				<span style="background: #ccccce;display: block;padding: 5px 8px;float: left">{$smarty.foreach.it.iteration}</span>
				{if $h.h_finished<2}
				<p style="float: left;margin: 0 40px">操作：<select class="querySelect" name="haul[{$h.h_tid}][item][{$i.hc_tid}][h_collect_type]" >{html_options options=$ctype selected=$i.h_collect_type}</select></p>
				<p style="float: left;margin: 0 40px">说明：<input
						class="infoTableInput" type="text"
						name="haul[{$h.h_tid}][item][{$i.hc_tid}][h_collect_des]" value="{$i.h_collect_des}" style="float: none"/></p>
				{else}
				<p style="float: left;margin: 0 40px">
					<input type="hidden" name="haul[{$h.h_tid}][item][{$i.hc_tid}][h_collect_type]" value="{$i.h_collect_type}">
					{if $i.h_collect_type==0}扫描{/if}
					{if $i.h_collect_type==1}输入{/if}
					{if $i.h_collect_type==2}数字输入{/if}
					{if $i.h_collect_type==3}拍照{/if}
					{if $i.h_collect_type==4}录音{/if}
				</p>
				<p style="float: left;margin: 0 40px">{$i.h_collect_des}</p>
				{if $i.h_collect_type<3}
				<p style="float: left;margin: 0 40px">{$i.h_collect_val}</p>
				{/if}
				{if $i.h_collect_type==3&&$i.ar!=null}
				{foreach from=$i.ar item=a}
				<a href="{$site_url}/{$a}" target="_blank"><img src="{$site_url}/{$a}" style="height:100px;width:100px"/></a>
				{/foreach}
				{/if}

				{if $i.h_collect_type==4&&$i.ar!=null}
				{foreach from=$i.ar item=a}
				<audio controls="controls">

					<source src="{$site_url}/{$a}" type="audio/ogg">

					你的浏览器太老了，请更新否则没法听语音
				</audio>
				{/foreach}
				{/if}
				{/if}
				<div style="clear: both"></div>
			</div>
			{/foreach}
			<div style="clear: both"></div>
		</div>
	</div>
	{/foreach}
	</div>
	{if $canedit&&$haullist}
	<table class="infoTable" style="padding: 0">
		<tr>
			<th style="padding: 5px"><input class="formbtn" type="Submit"
											name="Submit" value="{$lang.submit}" style="width:150px;margin-left: 20px"/></th>
			<td class="ptb20" colspan="7" style="text-align: left"></td>

		</tr></table>
	{/if}
</form>
{/if}
	<style>
		.left{float: left;padding: 20px}
		.mapdiv{height: 300px;width: 300px}
		.fontdiv{height: 30px;line-height: 30px}
	</style>
<!-- {if $waybill.wm_tid}} -->
<div class="jui-cut-label fn-mt25" style="margin-top: 20px">
	<div class="jui-message-bar">异常信息</div>
</div>
{foreach from=$exception item=e}
<div style="border-left: 4px solid #76b5ea;border-top: 1px solid #d3dae0;border-bottom: 1px solid #d3dae0;border-right: 1px solid #d3dae0;margin: 10px 10px 20px 20px;">
	<form method="post" enctype="multipart/form-data" id="exception_form" action="index.php?app=carload&act=exceptiondone">
		<input type="hidden" value="{$e.e_tid}" name="exp[{$e.e_tid}][e_tid]">
		<input type="hidden" value="{$e.e_w_tid}" name="wm_tid">
		<div class="left">
			<div class="fontdiv">类型：{if $e.e_type}{$e.e_type} /{/if} {$e.e_content}</div>
			<div class="fontdiv">时间：{$e.e_op_date|date:Y-m-d H:i}</div>
			<div class="fontdiv">位置：{$e.e_address}</div>
			<div id="allmap_{$e.e_tid}" class="mapdiv"></div>
			<script>
				var map = new BMap.Map("allmap_{$e.e_tid}");
				map.centerAndZoom(new BMap.Point({$e.e_lng}, {$e.e_lat}), 15);
				map.enableScrollWheelZoom();

				var point = new BMap.Point({$e.e_lng}, {$e.e_lat});
				var marker = new BMap.Marker(point);        // 创建标注
				map.addOverlay(marker);
			</script>
			<div style="clear: both"></div>
		</div>
		<div class="left">
			{if $e.e_text_note}
			<div class="fontdiv">文字：{$e.e_text_note}</div>
			{/if}
			{if $e.e_pic}
			<div class="">图片：
				{foreach from=$e.e_pic item=p}
				<a href="{$site_url}/{$p.ea_content}" target="_blank" style=""><img src="{$site_url}/{$p.ea_content}" style="height:100px;width:100px;vertical-align: top;"/></a>
				{/foreach}
				<div style="clear: both"></div>
			</div>
			{/if}
			{if $e.e_voice}
			{foreach from=$e.e_voice item=v}
			<div class="fontdiv" style="line-height: 50px;height: 50px;margin-top: 20px">录音：
				<audio controls="controls" style="vertical-align: top">
					<source src="{$site_url}/{$v.ea_content}" type="audio/ogg">
					你的浏览器太老了，请更新否则没法听语音
				</audio>
				{/foreach}
			</div>
			{/if}
			<div class="fontdiv" style="float: left;width: 168px">状态：{$e.e_staus}</div>
			<div class="fontdiv" style="float: left;width: 300px">处理人：<input type="text" name="exp[{$e.e_tid}][e_handle_person]" value="{$e.e_handle_person}" style="height: 23px;

    padding: 0px 5px;
    border: 1px solid #ccc;
    outline: 0;
    font-size: 14px;
    line-height: 19px;"/></div>
			<div style="clear: both"></div>
			<div class="fontdiv" style="position: relative;">时间：<input type="text" id="e_handle_date_{$e.e_tid}" name="exp[{$e.e_tid}][e_handle_date]" value="{if $e.e_handle_date}{$e.e_handle_date|date:Y-m-d H:i}{else}-{/if}" style="height: 23px;

    padding: 0px 5px;
    border: 1px solid #ccc;
    outline: 0;
    font-size: 14px;
    line-height: 19px;width: 350px"/><a href="javascript:void(0);" class="right_a" style="right: 70px;
    top: 2px;"><img src="templates/images/newadmin/rili.png" alt=""></a></div>
			<script>
				$('#e_handle_date_{$e.e_tid}').datetimepicker({changeMonth: true,changeYear: true});
			</script>
			<div class="fontdiv">备注：<textarea style=" width: 350px;height: 120px;

    padding: 0px 5px;
    border: 1px solid #ccc;
    outline: 0;
    font-size: 14px;
    line-height: 19px;" name="exp[{$e.e_tid}][e_handle_note]">{$e.e_handle_note}</textarea></div>
		</div>
		<div style="clear: both"></div>
		{if $e.e_staus!='已处理'}
		<table class="infoTable" style="padding: 0">
			<tr>
				<th style="padding: 5px">
					<input class="formbtn" type="Submit" 	name="Submit" value="{$lang.submit}" style="width:150px;margin-left: 20px"/>
				</th>
				<td class="ptb20" colspan="7" style="text-align: left"></td>

			</tr></table>
		{/if}
	</form>
</div>
{/foreach}
<!-- 	{/if} -->
<div style="display: none"  >
	<div id="hzlist">
		<iframe id="hzframe" width="" height="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>
<div style="display: none"  >
	<div id="pclist">
		<iframe id="pcframe" src="index.php?app=datarefer&act=choose&wid={$waybill.wm_tid}" width="" height="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>
<div style="display: none"  >
	<div id="oplist">
		<iframe id="opframe" width="" height="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>
<div style="display: none"  >
	<div id="maplist">
		<iframe id="mapframe" width="" height="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>
<div style="display: none"  >
	<div id="monitorlist">
		<iframe id="monitorframe" width="" height="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>
</div>
{include file="footer.html"}